package com.sgb.kjwl.view.ui.adapter.enterprise;

import android.content.Context;
import android.view.View;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.databinding.ItemServiceNodeBinding;
import com.sgb.kjwl.model.entity.enterprise.ServiceNodeListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.ArrayList;
import java.util.List;

import com.sgb.kjwl.R;

public class ServiceNodeAdpater extends BaseRecycleAdapter<ServiceNodeListEntity> {
    private boolean isPublishService = false;//是否展示编辑修改

    public ServiceNodeAdpater(Context context) {
        super(context, R.layout.item_service_node, new ArrayList<>());
    }
    public ServiceNodeAdpater(Context context,boolean isPublishService) {
        super(context, R.layout.item_service_node,  new ArrayList<>());
        this.isPublishService = isPublishService;
    }

    @Override
    public void convert(ItemViewHolder holder, ServiceNodeListEntity serviceNodeListEntity) {
        if(holder.getmBinding() instanceof ItemServiceNodeBinding) {
            holder.getmBinding().setVariable(BR.model, serviceNodeListEntity);
            ((ItemServiceNodeBinding) holder.getmBinding()).view.setVisibility(isPublishService? View.VISIBLE:View.GONE);
            ((ItemServiceNodeBinding) holder.getmBinding()).llUpdate.setVisibility(isPublishService? View.VISIBLE:View.GONE);
            ((ItemServiceNodeBinding) holder.getmBinding()).tvEdit.setOnClickListener(view ->{onItemClick.onItemClick(serviceNodeListEntity,-1);});
            ((ItemServiceNodeBinding) holder.getmBinding()).tvDelete.setOnClickListener(view ->{onItemClick.onItemClick(serviceNodeListEntity,-2);});
        }
    }
}
